package com.du.cloud.common.base.utils;

import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.UUID;

/**
 * Desc: 获取随机数
 * Author: dushuang
 * Date: Create in 2018/5/2
 */
@Slf4j
public class UidUtil {

    /***
     * @param length [max=32]
     * @return
     */
    public static String getRandomUid(int length){
        if(length > 32){
            log.error("超过随机数最大长度!");
            return "";
        }
        return IdUtil.fastSimpleUUID().substring(0, length);
    }
    public static String getRandomUid(){
        return getRandomUid(32);
    }

}
